//
//  FinishedSubFooter.m
//  RRQS
//
//  Created by kyjun on 16/3/29.
//
//

#import "FinishedSubFooter.h"

@interface FinishedSubFooter ()

@property(nonatomic,strong) UIButton* btnIcon;
@property(nonatomic,strong) UILabel* labelSendAddress;
@property(nonatomic,strong) UIView* lineView;
@property(nonatomic,strong) UIView* line1View;

@property(nonatomic,strong) UIView* topView;
@property(nonatomic,strong) UIView* midView;
@property(nonatomic,strong) UIView* bottomView;


@property(nonatomic,strong) UILabel* typeLabel;
@property(nonatomic,strong) UILabel* timeLabel;



@property(nonatomic,strong) UILabel* moneyLabel;
@property(nonatomic,strong) UIImageView* arrowImageView;

@end

@implementation FinishedSubFooter

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){         
        [self layoutUI];

    }
    return self;
}

#pragma mark =====================================================  user inferface layout
-(void)layoutUI{
    
    self.topView = [[UIView alloc] init];
    [self addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.mas_equalTo(35);
    }];
    
    
    [self.topView addSubview:self.btnIcon];
    [self.topView addSubview:self.labelSendAddress];
    [self addSubview:self.lineView];

    
    [self.btnIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.topView);
        make.left.equalTo(self.topView).offset(10);
        make.height.width.mas_equalTo(25);

    }];
    
    [self.labelSendAddress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.topView);
        make.left.equalTo(self.btnIcon.mas_right).offset(10);
    }];
    
    
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(0.8);
    }];
    
    
    self.midView = [[UIView alloc] init];
    [self addSubview:self.midView];
    [self.midView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom);
        make.left.right.equalTo(self.topView);
        make.height.mas_equalTo(50);
    }];
    
    [self.midView addSubview:self.typeLabel];
    [self.midView addSubview:self.timeLabel];
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.midView);
        make.left.equalTo(self.midView).offset(10);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.midView);
        make.right.equalTo(self.midView).offset(-10);
    }];
    
    
    
    [self addSubview:self.line1View];
    [self.line1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.midView.mas_bottom);
        make.left.right.height.equalTo(self.lineView);
    }];
    
    
    self.bottomView = [[UIView alloc] init];
    [self addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line1View.mas_bottom);
        make.left.right.equalTo(self.topView);
        make.height.mas_equalTo(35);
    }];
    
    
    
    [self.bottomView addSubview:self.moneyLabel];
    [self.bottomView addSubview:self.arrowImageView];
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bottomView);
        make.left.equalTo(self.bottomView).offset(10);
    }];
    
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bottomView);
        make.right.equalTo(self.midView).offset(-10);
        make.height.mas_equalTo(15);
        make.width.mas_equalTo(8);

    }];
    
    
    
    
    
    
}


#pragma mark =====================================================  property package
-(void)setEntity:(MOrder *)entity{
    if(entity){
        _entity = entity;
        self.labelSendAddress.text = entity.address;
        self.typeLabel.text = [NSString stringWithFormat:@"%@",entity.dantype];
        self.timeLabel.text = [NSString stringWithFormat:@"%@\n用时%@", entity.send_time,entity.xd_time];

        self.moneyLabel.text = [NSString stringWithFormat:@"交易金额：%@",entity.shipping_fee];

        
    }
}

-(UIButton *)btnIcon{
    if(!_btnIcon){
        _btnIcon = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnIcon setImage:[UIImage imageNamed:@"icon-sendStatus-light"] forState:UIControlStateNormal];
    }
    return _btnIcon;
}

-(UILabel *)labelSendAddress{
    if(!_labelSendAddress){
        _labelSendAddress = [[UILabel alloc]init];
        _labelSendAddress.numberOfLines = 0;
        _labelSendAddress.font = [UIFont systemFontOfSize:14.f];
    }
    return _labelSendAddress;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView  = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithRed:231/255.0f green:231/255.0f blue:231/255.0f alpha:1.0f];
    }
    return _lineView;
}

-(UIView *)line1View{
    if(!_line1View){
        _line1View  = [[UIView alloc]init];
        _line1View.backgroundColor = [UIColor colorWithRed:231/255.0f green:231/255.0f blue:231/255.0f alpha:1.0f];
    }
    return _line1View;
}


-(UILabel *)typeLabel{
    if(!_typeLabel){
        _typeLabel = [[UILabel alloc]init];
        _typeLabel.font = [UIFont systemFontOfSize:12.f];
        _typeLabel.textColor = [UIColor colorWithRed:90/255.f green:90/255.f blue:90/255.f alpha:1.0];
        
    }
    return _typeLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.numberOfLines = 0;
        _timeLabel.textAlignment = NSTextAlignmentRight;
        _timeLabel.font = [UIFont systemFontOfSize:12.f];
        _timeLabel.textColor = [UIColor colorWithRed:90/255.f green:90/255.f blue:90/255.f alpha:1.0];
        
    }
    return _timeLabel;
}


-(UILabel *)moneyLabel{
    if(!_moneyLabel){
        _moneyLabel = [[UILabel alloc]init];
        _moneyLabel.font = [UIFont systemFontOfSize:12.f];
        _moneyLabel.textColor = [UIColor colorWithRed:90/255.f green:90/255.f blue:90/255.f alpha:1.0];
        
    }
    return _moneyLabel;
}

-(UIImageView *)arrowImageView{
    if(!_arrowImageView){
        _arrowImageView = [[UIImageView alloc]init];
        [_arrowImageView setImage:[UIImage imageNamed:@"icon-arrow-right"]];
    }
    return _arrowImageView;
}


@end
